using System;
using System.Data;

using Geekees.App.Cashbook.Lib.Entity;
using Geekees.App.Cashbook.Lib.DAL;
using Geekees.App.Cashbook.Lib.Helper;

namespace Geekees.App.Cashbook.Lib.BLL
{
	/// <summary>
	/// Summary description for BLLSecurity.
	/// </summary>
	public class BLSecurity
	{
		public BLSecurity()
		{
			
		}

		public static int AddUser( string userName, string displayName, string pwd )
		{
			return DASecurity.AddUser( userName, displayName, pwd );
		}

		public static bool IsUserExist( string userName )
		{ 
			return DASecurity.IsUserExist( userName );
		}

		public static User LoginUser( string userName, string pwd )
		{
			return DASecurity.LoginUser( userName, pwd );
		}

		public static User LoginUserUsingTicket( string userName, string ticket )
		{
			return DASecurity.LoginUserUsingTicket( userName, ticket );
		}

		public static bool UpdateLastLoginTime( string userName, DateTime t )
		{
			return DASecurity.UpdateLastLoginTime( userName, t );
		}

		public static bool UpdateLastChangePasswordTime( string userName, DateTime t )
		{
			return DASecurity.UpdateLastChangePasswordTime( userName, t );
		}

		public static bool UpdateTicket( string userName, string ticket )
		{
			return DASecurity.UpdateTicket( userName, ticket );
		}

		public static bool CheckLogin( string userName, string pwd )
		{
			return DASecurity.CheckLogin( userName, pwd );
		}

		public static bool ChangePassword( string userName, string oldpwd, string newpwd )
		{
			if( !CheckLogin( userName, oldpwd ) )
				return false;

			return DASecurity.UpdatePassword( userName, newpwd );
		}


	}
}
